package model.album;

public class AlbumPagingBean {
	private int totalContent;
	private int nowPage;
	private int numberOfContentPerPage=AlbumCommonConstants.CONTENT_NUMBER_PER_PAGE;
	private int numberOfPageGroup=AlbumCommonConstants.PAGEGROUP_NUMBER_PER_PAGE;
	
	public AlbumPagingBean(int totalContent,int nowPage){
		this.totalContent=totalContent;
		this.nowPage=nowPage;
	}
	public int getNowPage(){
		return nowPage;
	}
	
	public int getTotalPage(){
		int num=totalContent%this.numberOfContentPerPage;
		int tatalPage=0;
		if(num==0){
			tatalPage=totalContent/numberOfContentPerPage;
		}else{
			tatalPage=totalContent/numberOfContentPerPage+1;
		}
		return tatalPage;
	}
	
	public int getTotalPageGroup(){
		int num=getTotalPage()%this.numberOfPageGroup;
		int totalGroup=0;
		if(num==0){
			totalGroup=getTotalPage()/this.numberOfPageGroup;
		}else{
			totalGroup=getTotalPage()/this.numberOfPageGroup+1;
		}
		return totalGroup;
	}
	
	public int getNowPageGroup(){
		int num=nowPage%this.numberOfPageGroup;
		int nowGroup=0;
		if(num==0){
			nowGroup=nowPage/this.numberOfPageGroup;
		}else{
			nowGroup=nowPage/this.numberOfPageGroup+1;
		}
		return nowGroup;
	}
	
	public int getStartPageOfPageGroup(){
		int start=this.numberOfPageGroup*(getNowPageGroup()-1)+1;
		return start;
	}
	
	public int getEndPageOfPageGroup(){
		int end=this.getNowPageGroup()*this.numberOfPageGroup;
		if(end>this.getTotalPage()){
			end=this.getTotalPage();
		}
		return end;
	}
	
	public boolean isPreviousPageGroup(){
		boolean flag=false;
		if(this.getNowPageGroup()>1)
			flag=true;
		return flag;
	}
	
	public boolean isNextPageGroup(){
		boolean flag=false;
		if(this.getNowPageGroup()<this.getTotalPageGroup()){
			flag=true;
		}
		return flag;
	} 
}
